package com.nantian.ecm.cebecm.concurrentframe;

import java.util.concurrent.*;

public class TaskExecutor {
	private static final int DEFAULT_THREAD_COUNT = 10;
	private int threadCount = DEFAULT_THREAD_COUNT;
	private ExecutorService execSvc = Executors.newFixedThreadPool(threadCount);

	public void execute(Task task) {
		for (int i = 0; i < threadCount; i++) {
			execSvc.execute(task);
		}
	}

	public void shutdown() {
		execSvc.shutdown();
	}

	public int getThreadCount() {
		return threadCount;
	}

	public void setThreadCount(int threadCount) {
		this.threadCount = threadCount;
		execSvc=null;
		execSvc = Executors.newFixedThreadPool(threadCount);
	}
}
